package com.agriculture.domain;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;

public class Order {
    private Long orderId;
    private String orderType;   // purchase, sales
    private String status;      // pending_payment, completed, cancelled, pending_review...
    private Date createdAt;
    private BigDecimal totalAmount;
    private String buyerName;
    private Long buyerId;
    private Long sellerId;
    private String shippingAddress;
    private String trackingNumber;
    private String notes;
    private List<OrderItem> orderItems = new ArrayList<>();
    private String lastOperator;
    private Date lastOperationTime;
    private Date paymentTime;
    private Date completionTime;
    private Date approvalTime;
    private Date acceptanceTime;
    private Date shipmentTime;
    private Date cancellationTime;
    private String cancelReason;
    private Date cancelTime;
    private Date receiptTime;
    private String sellerName;

    public Order() {
        this.orderItems = new ArrayList<>();
    }

    public Order(Long orderId, String orderType, String status, Date createdAt, BigDecimal totalAmount, String buyerName, Long buyerId, Long sellerId, String shippingAddress, String trackingNumber, Date paymentTime, Date completionTime, String notes, List<OrderItem> orderItems) {
        this.orderId = orderId;
        this.orderType = orderType;
        this.status = status;
        this.createdAt = createdAt;
        this.totalAmount = totalAmount;
        this.buyerName = buyerName;
        this.buyerId = buyerId;
        this.sellerId = sellerId;
        this.shippingAddress = shippingAddress;
        this.trackingNumber = trackingNumber;
        this.paymentTime = paymentTime;
        this.completionTime = completionTime;
        this.notes = notes;
        this.orderItems = orderItems;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public String getBuyerName() {
        return buyerName;
    }

    public void setBuyerName(String buyerName) {
        this.buyerName = buyerName;
    }

    public Long getBuyerId() {
        return buyerId;
    }

    public void setBuyerId(Long buyerId) {
        this.buyerId = buyerId;
    }

    public Long getSellerId() {
        return sellerId;
    }

    public void setSellerId(Long sellerId) {
        this.sellerId = sellerId;
    }

    public String getShippingAddress() {
        return shippingAddress;
    }

    public void setShippingAddress(String shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    public String getTrackingNumber() {
        return trackingNumber;
    }

    public void setTrackingNumber(String trackingNumber) {
        this.trackingNumber = trackingNumber;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public List<OrderItem> getOrderItems() {
        return orderItems;
    }

    public void setOrderItems(List<OrderItem> orderItems) {
        this.orderItems = orderItems;
    }

    public String getLastOperator() {
        return lastOperator;
    }

    public void setLastOperator(String lastOperator) {
        this.lastOperator = lastOperator;
    }

    public Date getLastOperationTime() {
        return lastOperationTime;
    }

    public void setLastOperationTime(Date lastOperationTime) {
        this.lastOperationTime = lastOperationTime;
    }

    public Date getPaymentTime() {
        return paymentTime;
    }

    public void setPaymentTime(Date paymentTime) {
        this.paymentTime = paymentTime;
    }

    public Date getCompletionTime() {
        return completionTime;
    }

    public void setCompletionTime(Date completionTime) {
        this.completionTime = completionTime;
    }

    public Date getApprovalTime() {
        return approvalTime;
    }

    public void setApprovalTime(Date approvalTime) {
        this.approvalTime = approvalTime;
    }

    public Date getAcceptanceTime() {
        return acceptanceTime;
    }

    public void setAcceptanceTime(Date acceptanceTime) {
        this.acceptanceTime = acceptanceTime;
    }

    public Date getShipmentTime() {
        return shipmentTime;
    }

    public void setShipmentTime(Date shipmentTime) {
        this.shipmentTime = shipmentTime;
    }

    public Date getCancellationTime() {
        return cancellationTime;
    }

    public void setCancellationTime(Date cancellationTime) {
        this.cancellationTime = cancellationTime;
    }

    public String getCancelReason() {
        return cancelReason;
    }

    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }

    public Date getCancelTime() {
        return cancelTime;
    }

    public void setCancelTime(Date cancelTime) {
        this.cancelTime = cancelTime;
    }

    public Long getProductId() {
        if (!orderItems.isEmpty()) {
            return orderItems.get(0).getProductId();
        }
        return null;
    }

    public Integer getQuantity() {
        if (!orderItems.isEmpty()) {
            return orderItems.get(0).getQuantity();
        }
        return null;
    }

    public void setReceiptTime(Date date) {
        this.receiptTime = date;
    }

    public Date getReceiptTime() {
        return receiptTime;
    }

    public String getSellerName() {
        return sellerName;
    }

    public void setSellerName(String sellerName) {
        this.sellerName = sellerName;
    }
}